sched_credit: Hold lock while dump scheduler info
authorKeir Fraser <keir@xen.org>
Sat, 5 Mar 2011 11:36:21 +0000 (11:36 +0000)
committerKeir Fraser <keir@xen.org>
Sat, 5 Mar 2011 11:36:21 +0000 (11:36 +0000)
commite00d02009db149c6b9ee52da9d0907e9fe362a23
treebf883ef26aa6e3e475850cab78c1256c4b2b5a9a
parent87fe7478aa597f8b9b744d19e3b79a64f3d9cf15
sched_credit: Hold lock while dump scheduler info

Dump runq with debug key 'r' may cause dead loop like below:

(XEN) active vcpus:
(XEN)     1: [1.0] pri=0 flags=0 cpu=0 credit=263 [w=256]
(XEN)     2: [0.2] pri=0 flags=0 cpu=5 credit=284 [w=256]
(XEN)     3: [0.2] pri=0 flags=0 cpu=5 credit=282 [w=256]
...
(XEN)  xxxxx: [0.2] pri=0 flags=0 cpu=2 credit=54 [w=256]
...
(XEN)  xxxxx: [0.2] pri=0 flags=0 cpu=3 credit=-48 [w=256]
...

This means the active vcpu 0.2 became non-active with the active list
element empty just after it was accessed in the loop '2:'.

We should always hold a lock before access scheduler related list,
even in the debug purpose dump code.

Signed-off-by: Wei Gang <gang.wei@intel.com>
xen/common/sched_credit.c